<?php 
$weekarr = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$week = $weekarr[date("w")];
?>
<div id="candidate" class="indexcontentdiv">
    <div class="positiondiv">
        <table>
            <tr>
                <td class="td-left">
                    <img src="<?=base_url()?>resource/img/home_ico.png" width="21" height="17">
                    Setting > Employee
                </td>
                <td class="td-right">
                    <img src="<?=base_url()?>resource/img/menu2.png" width="27" height="24">Today is <?=$week?>,<?=date('M d,Y')?>
                </td>
            </tr>
        </table>
    </div>
    <div class="list-div">
        <?php echo form_open('user/employee'); ?>
        <table class="top-table">
            <tr>
                <td>Employee List</td>
                <td width="240" class="center"><input type="text" placeholder="input name" 
                    name="condition" value="<?=$condition?>"/></td>
                <td width="90" class="center"><input type="submit" value="Search" /></td>
                <td width="110" class="center"><input type="button" value="New" id="new"/></td>
            </tr>
        </table>
        <?php echo form_close(); ?>
        <table class="list-table">
            <tr>
                <th width="60">ID</th>
                <th width="100">IC NO</th>
                <th width="100">Name</th>
                <th width="100">Department</th>
                <th width="100">Position</th>
                <th>Birthday</th>
                <th>Username</th>
                <th width="100"></th>
                <th width="100"></th>
            </tr>
            <?php foreach ($employee as $key => $value) {?>
            <tr>
                <td><?=$value['id']?></td>
                <td><?=$value['sn']?></td>
                <td><?=$value['name']?></td>
                <td><?=$value['department']==1?"Office":($value['department']==2?"Marketing":"Logistics")?></td>
                <td><?=$value['position']?></td>
                <td><?=$value['birthday']?></td>
                <td><?=$value['username']?></td>
                <td><a href="javascript:void(0)" class="buttona detail" candidateid="<?=$value['id']?>">
                        <img src="<?=base_url()?>resource/img/detail.png"/>edit</a></td>
                <td><a href="<?=base_url('user/delete_employee').'?id='.$value['id'] ?>" class="buttona">
                        <img src="<?=base_url()?>resource/img/delete.png"/>delete</a></td>
            </tr>
            <?php }
            if(count($employee) == 0){?>
            <tr>
                <td colspan="7">
                    NO DATA
                </td>
            </tr>
            <?php }?>
            <tr>
                <td colspan="7" class="pagination">
                    <?php echo $page;?>
                </td>
            </tr>
        </table>
    </div>
</div>
<script>
$("#new").click(function(){
    var url = '<?=base_url()?>user/new_employee';
    location.href=url;
});

$(".detail").click(function(){
    var id = $(this).attr("candidateid");
    var url = '<?=base_url()?>user/employee_detail/'+id;
    location.href=url;
});
</script>
